<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        //创建一个用户迭代数组的迭代器
        function createArrayIterator(arr) {
            var i = 0; //下标从0开始迭代
            return {
                next() {
                    return {
                        value: arr[i++],
                        done: i > arr.length
                    }
                }
            }
        }

        var iterator = createArrayIterator([3, 6, 7, 2, 1, 3]);
    </script>
</body>

</html>
